package jdk5.misc;

public enum TrafficLight implements java.io.Serializable {
    
     RED(30){
           public  TrafficLight next() { return GREEN; }
     }, 
     
    AMBER(10){
           public  TrafficLight next() { return RED; }
     },

   GREEN(40){
           public  TrafficLight next() { return AMBER; }
     };

     private final int duration;
     TrafficLight(int duration){ this.duration = duration; }
    
     public int duration() { return duration; }

     public abstract TrafficLight next();

     public static void main(String[] args){
             for(TrafficLight light : TrafficLight.values()){
                     System.out.print(light);
                     System.out.println( "\t" + light.duration());
             }
     }
}

